package qy.qyalgotrader.ts;

import org.apache.commons.collections4.MapUtils;
import qy.qyalgotrader.utils.CommonDataUtils;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
public final class TsDataUtils {

	/**
	 *
	 */
	private final static Map<String, String> TS_INDEX_MAP = MapUtils.putAll(new HashMap<>(), new Object[][] {
			{ "000001.SH", "sh" }, // 上证指数
			{ "399001.SZ", "sz" }, // 深证成指
			{ "000300.SH", "hs300" }, // 沪深 300 指数
			{ "000016.SH", "sz50" }, // 上证 50 指数
			{ "399005.SZ", "zxb" }, // 中小板指
			{ "399006.SZ", "cyb" }, // 创业板指
			{ "399008.SZ", "zx300" }, // 中小 300 指数
			{ "000905.SH", "zh500" } // 中证 500 指数
	});

	/**
	 * e.g.: "601318.SH" -&gt; "601318", "000300.SH" -&gt; "hs300"
	 *
	 * @param wc windcode
	 * @return tushare code
	 */
	public static String windCodeToTsCode(String wc) {

		if (TS_INDEX_MAP.containsKey(wc)) {
			return TS_INDEX_MAP.get(wc);
		} else {
			return CommonDataUtils.windCodeToCode(wc);
		}
	}

	private TsDataUtils() {

	}
}
